package Bai3;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import org.omg.CORBA_2_3.portable.OutputStream;

import com.sun.org.apache.regexp.internal.recompile;

public class HomeWork {
	//attribute: day so nguyen a
	private List<Integer> list;
	
	//constructor
	public HomeWork() {
		list = new ArrayList<Integer>();
	}
	
	//method: nhap gia tri cho day(list) a tu file input1.txt
	public void enterDataFormFileToList(String file) {
		Scanner scanner;
		File f = new File("input1.txt");
		
		try {
			scanner = new Scanner(f);
			
			while(scanner.hasNext()) {
				int n = scanner.nextInt();
				list.add(n);
				
			}
		}
		catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	//method: ghi gia tri tung phan tu cua a vao file output1.txt
	public void writeAllDataToFile(String file) {
		FileOutputStream fOut;
		
		try {
			fOut = new FileOutputStream("input1.txt");
			PrintWriter pW = new PrintWriter(fOut, true);
			
			for(int i = 0; i < list.size(); i++) {
				pW.println(list.get(i));
			}
			
			fOut.close();
			pW.close();
		}
		catch (Exception e) {
			System.out.print("Couldn't write file");
		}
	}
	
	//method: nhap gia tri cho day(list) bat ki, dau vao la file input2.txt
	
	//method: ghi tung phan tu cua day bat ki vao file input2.txt
	
	//method: tim so chan trong day a
	
	//method: ghi tat ca cac so chan trong day a vao file chan.txt
	
	//method: tim tat ca cac so nguyen to trong day a
	
	//method: ghi tat cac cac so nguyen to trong day a vao file nguyento.txt
}
